package cn.backpackerxl.service.impl;

import cn.backpackerxl.dao.UserDao;
import cn.backpackerxl.easyJDBC.main.EasyJDBCRepository;
import cn.backpackerxl.entity.User;
import cn.backpackerxl.service.UserService;

import java.util.List;

/**
 * @Author: backpackerxl
 * CreateTime: 2022/5/18
 * FileName: UserServiceImpl
 **/
public class UserServiceImpl implements UserService {
    private final UserDao userDao = (UserDao) new EasyJDBCRepository(UserDao.class).init();

    @Override
    public int add(User user) {
        return userDao.save(user);
    }

    @Override
    public List<User> all() {
        return userDao.findAll();
    }

    @Override
    public User findUser(Long id) {
        return userDao.findById(id);
    }

    @Override
    public int update(User user) {
        return userDao.update(user);
    }
}
